<?php

/**
 * This is the model class for table "{{ref_apply}}".
 *
 * The followings are the available columns in table '{{ref_apply}}':
 * @property integer $zda_id
 * @property string $zo_id
 * @property integer $zp_id
 * @property integer $zm_id
 * @property integer $zra_nums
 * @property string $zra_content
 * @property integer $zra_type
 * @property integer $zra_status
 * @property string $zra_note
 */
class RefApply extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return RefApply the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{ref_apply}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zo_id, zp_id, zm_id, zra_nums, zra_content, zra_status', 'required'),
			array('zp_id, zm_id, zra_nums, zra_type, zra_status', 'numerical', 'integerOnly'=>true),
			array('zo_id', 'length', 'max'=>20),
			array('zra_content', 'length', 'max'=>255),
			array('zra_note', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zda_id, zo_id, zp_id, zm_id, zra_nums, zra_content, zra_type, zra_status, zra_note', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zda_id' => 'Zda',
			'zo_id' => 'Zo',
			'zp_id' => 'Zp',
			'zm_id' => 'Zm',
			'zra_nums' => 'Zra Nums',
			'zra_content' => 'Zra Content',
			'zra_type' => 'Zra Type',
			'zra_status' => 'Zra Status',
			'zra_note' => 'Zra Note',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zda_id',$this->zda_id);
		$criteria->compare('zo_id',$this->zo_id,true);
		$criteria->compare('zp_id',$this->zp_id);
		$criteria->compare('zm_id',$this->zm_id);
		$criteria->compare('zra_nums',$this->zra_nums);
		$criteria->compare('zra_content',$this->zra_content,true);
		$criteria->compare('zra_type',$this->zra_type);
		$criteria->compare('zra_status',$this->zra_status);
		$criteria->compare('zra_note',$this->zra_note,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}